/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainPage.java
 *
 * Created on Apr 1, 2012, 6:48:51 PM
 */
package blackjack;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Tejas
 */
public class MainPage extends javax.swing.JFrame {
    
    private int currentCard = 1;
    private JPanel cardPanel;
    private CardLayout cl;

    /** Creates new form MainPage */
    public MainPage() {
        setTitle("Card Layout Example");
                setSize(600, 450);
                cardPanel = new JPanel();

                cl = new CardLayout();
                cardPanel.setLayout(cl);
                JPanel singlePlayer = new JPanel();
                JPanel multiPlayer = new JPanel();
                JPanel mainPage = new JPanel();
                
                mainPage.setLayout(new GridLayout(3,0,1,1));
                singlePlayer.setLayout(new GridLayout());
                multiPlayer.setLayout(new GridLayout());
                
                
                JLabel singlePlayerLabel = new JLabel("Single Player", JLabel.CENTER);
                JLabel multiPlayerLabel = new JLabel("Multi Player", JLabel.CENTER);
                JLabel mainPageLabel = new JLabel("BlackJack!!", JLabel.CENTER);
               
                singlePlayer.add(singlePlayerLabel);
                multiPlayer.add(multiPlayerLabel);
                mainPage.add(mainPageLabel);
                
                JButton singlePlayerBtn = new JButton("SinglePlayer");
                JButton multiPlayerBtn = new JButton("Multi Player");
                singlePlayerBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
                            currentCard = 2;
                            cl.show(cardPanel, "" + (currentCard));
//                                if (currentCard > 1) {
//                                        currentCard -= 1;
//                                        cl.show(cardPanel, "" + (currentCard));
//                                }
                        }
                });
                multiPlayerBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
                            currentCard = 3;
                            cl.show(cardPanel, "" + (currentCard));
//                                if (currentCard > 1) {
//                                        currentCard -= 1;
//                                        cl.show(cardPanel, "" + (currentCard));
//                                }
                        }
                });
                mainPage.add(singlePlayerBtn);
                mainPage.add(multiPlayerBtn);
            
                cardPanel.add(mainPage, "1");
                cardPanel.add(singlePlayer, "2");
                cardPanel.add(multiPlayer, "3");
               
                JPanel buttonPanel = new JPanel();
                JButton mainPageBtn = new JButton("Home");
                buttonPanel.add(mainPageBtn);
                
                mainPageBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
                            currentCard = 1;
                            cl.show(cardPanel, "" + (currentCard));
//                                if (currentCard > 1) {
//                                        currentCard -= 1;
//                                        cl.show(cardPanel, "" + (currentCard));
//                                }
                        }
                });
                
                
                getContentPane().add(cardPanel, BorderLayout.PAGE_START);
                
                getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
